package com.dona.imsidetector.db.dao;

import com.dona.imsidetector.db.XUtilsManager;
import com.dona.imsidetector.db.entity.BwList;

import org.xutils.DbManager;
import org.xutils.ex.DbException;

import java.util.List;

public class ListDao {

    private static DbManager dbManager = XUtilsManager.getInstance().getDbManager();


    public static String add(BwList bwList){

        try {
            dbManager.save(bwList);
        }catch (DbException e){
            e.printStackTrace();
            return e.getMessage();
        }
        return null;
    }

    public static String clear(){
        try {
            dbManager.delete(BwList.class);
        }catch (DbException e){
            e.printStackTrace();
            return e.getMessage();
        }
        return null;
    }

    public static String delete(BwList bwList){
        try {
            dbManager.delete(bwList);
        }catch (DbException e){
            e.printStackTrace();
            return e.getMessage();
        }
        return null;
    }

    public static BwList find(String uuid){
        try {
            return dbManager.selector(BwList.class).where("uuid","=", uuid).findFirst();
        }catch (DbException e){
            e.printStackTrace();
        }
        return null;
    }

    public static List<BwList> findAll(){
        try {

            return dbManager.selector(BwList.class).orderBy("create_time",true).findAll();
        }catch (DbException e){
            e.printStackTrace();
            return null;
        }
    }




}
